﻿using System;
using System.Collections.Generic;
using System.Text;
using IService.Data.IManager;
using System.Data;
using IService.DataDLL;
using IService.Model;

namespace IService.Data.OlbImpl.ManagerImpl
{
    public class SupplyPurchaseDataManagerImpl : ISupplyPurchaseDaManager
    {
        public DataTable GetSupplyPurchaseListAll(Type infoType)
        {
            return DataAccess.SelectAll(infoType);
        }

        public DataTable GetSupplyPurchaseListPagin(Type infoType, PagingEntity pe)
        {
            return DataAccess.SelectPaging(infoType, pe);
        }

        public DataTable GetLatestSupplyPurchaseList(Type infoType, int supplyPurchasenum,string whereClause)
        {
            string WhereClause = whereClause;
            string Order = "CreateDate desc";
            return DataAccess.SelectTop(infoType, supplyPurchasenum, WhereClause, Order);
        }

        public DataTable GetLatestSupplyPurchaseListByType(Type infoType, int supplyPurchasenum, int type)
        {
            string WhereClause = "[ShowWebsite]=true and [NewsTypeId]=" + type;
            string Order = "CreateDate desc";
            return DataAccess.SelectTop(infoType, supplyPurchasenum, WhereClause, Order);
        }

        public SupplyPurchase GetSupplyPurchaseById(SupplyPurchase supplyPurchase)
        {
            supplyPurchase.Select();
            return supplyPurchase;
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="SupplyPurchase"></param>
        /// <returns></returns>
        public bool InsertSupplyPurchase(SupplyPurchase supplyPurchase)
        {
            return DataAccess.Insert(supplyPurchase);
        }

        public bool UpdateSupplyPurchase(SupplyPurchase supplyPurchase)
        {
            return DataAccess.Update(supplyPurchase);
        }

        public bool DeleteSupplyPurchase(SupplyPurchase supplyPurchase)
        {
            return DataAccess.Delete(supplyPurchase);
        }

        public bool DeleteSupplyPurchaseByIds(Type infoType, string Ids)
        {
            string WhereClause = "Id in(" + Ids + ")";
            return DataAccess.Delete(infoType, WhereClause);
        }
    }
}
